package guis;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

public class ModalWindow extends JFrame
{
	private static final long	serialVersionUID	= 1032307379765488755L;
	protected JFrame			source;

	public ModalWindow( String title, JFrame source )
	{
		super( title );
		this.source = source;
		initialize();
		createActions();
	}

	private void initialize()
	{
		this.setResizable( false );
		this.setLayout( null );
		this.setVisible( true );
		if( source != null ) source.setEnabled( false );
	}

	private void createActions()
	{
		this.addWindowListener( new WindowAdapter() {

			@Override
			public void windowClosing( WindowEvent arg0 )
			{
				if( source != null ) source.setEnabled( true );
			}

		});
	}
}
